<?php

namespace App;


use Illuminate\Foundation\Auth\User;
use Illuminate\Notifications\Notifiable;

class AdminUser extends User
{
     use Notifiable;
     protected $rememberTokenName = '';
     protected $guarded=[];
     public function roles(){
     		return $this->belongsToMany('App\AdminRole','admin_role_users','user_id','role_id')->withPivot('user_id', 'role_id');

     }
     //交集
     public function haspe($roles){
     	return  !!$roles->intersect($this->roles)->count();
     }
     public function hasPermission($permission){
     	return $this->haspe($permission->roles);
     }
    

}
